Coviarance and Contravariance : Connict without a Cause Covariance and Contravariance: Connict without a Cause

نویسندگان

  • Giuseppe CASTAGNA
  • Giuseppe Castagna
چکیده

In type theoretic research on object-oriented programming the \covariance versus con-travariance issue" is a topic of continuing debate. In this short note we argue that covari-ance and contravariance appropriately characterize two distinct and independent mechanisms. The so-called contravariance rule correctly captures the substitutivity, or subtyping relation (that establishes which sets of codes can replace in every context another given set). A covariant relation, instead, characterizes the specialization of code (i.e. the deeni-tion of new code that replaces the old one in some particular cases). Therefore, covariance and contravariance are not opposing views, but distinct concepts that each have their place in object-oriented systems and that both can (and should) be type safely integrated in an object-oriented language. We also show that the independence of the two mechanisms is not characteristic of a particular model but is valid in general, since covariant specialization is present also in record-based models, but is hidden by a deeciency of all calculi that realize this model. As an aside, we show that the &-calculus CGL92] can be taken as the basic calculus both for an overloading-based and for a record-based model. In that case, one not only obtains a more uniform vision of object-oriented type theories but, in the case of the record-based approach, one also gains multiple dispatching, which is not captured by the existing record-based models.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Covariance and Contravariance:conflict without a Cause Covariance and Contravariance: Connict without a Cause

In type theoretic research on object-oriented programming the \covariance versus con-travariance issue" is a topic of continuing debate. In this short note we argue that covari-ance and contravariance appropriately characterize two distinct and independent mechanisms. The so-called contravariance rule correctly captures the substitutivity, or subtyping relation (that establishes which sets of c...

متن کامل

Covariance and Contravariance: Connict without a Cause

In type-theoretic research on object-oriented programming, the issue of \covariance versus con-travariance" is a topic of continuing debate. In this short note we argue that covariance and con-travariance appropriately characterize two distinct and independent mechanisms. The so-called contravariancerule correctly captures the subtyping relation (that relation which establishes which sets of fu...

متن کامل

Covariance and Contravariance: a fresh look at an old issue

Twenty years ago, in an article titled “Covariance and contravariance: conflict without a cause”, I argued that covariant and contravariant specialization of method parameters in object-oriented programming had different purposes and deduced that, not only they could, but actually they should both coexist in the same language. In this work I reexamine the result of that article in the light of ...

متن کامل

Spécialisation et sous-typage : thème et variations

Class specialization is the most original feature of object orientation, but identifying it to subtyping leads to the well known covariance-contravariance controversy. Type safety requires contravariance while specialization needs covariance. This paper aims to precisely analyse this problem, to show how irreductible it is and the need for type errors. We show that many alternatives as multiple...

متن کامل

Covariance, Contravariance, and Synchronization Constraints

Object Orientation and concurrent progamming are a natural match. Objects correspond to processes in a concurrent program; a message from one object to another invoking a method of the latter, corresponds naturally to (message passing) interaction between processes in a concurrent program. Despite this close correspondence, progress in developing an OO approach to concurrency has been limited. ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1994